const express = require('express');

const app = express();

// 定义中间件
const middleware1 = (req, res, next) => {

  next();
}

// 作为全局中间件使用
// app.use(middleware1)
// 作为局部中间件使用

app.use('/news', middleware1)




app.get('/home', (req, res) => {
  res.send('home的get')
});
app.get('/news', (req, res) => {
  
  res.send('news')
});
app.get('/about', (req, res) => {
  console.log(req.query);
  res.send('about')
});
app.post('/home', (req, res) => {
  console.log(req.body);
  res.send('home的post')
})

app.listen(3000, () => {
  console.log('start at port 3000');
})